package com.class04.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/12/12 16:46
 */
@RestController
@RequestMapping("user")
public class UserController {
    @GetMapping
    public String data() {
        String str = null;
//        NullPointerException
        String s = str.toUpperCase();
        System.out.println("s = " + s);
        return "hello";
    }

    @GetMapping("data1")
    public Integer data1() {
        int[] ints = new int[2];
        ints[0] = 1;
        ints[1] = 1;
//        ArrayIndexOutOfBoundsException
        ints[2] = 1;
        ints[3] = 1;
        return ints[3];

    }

    @GetMapping("data2")
    public String data2() {
        //        ArithmeticException
        int i = 1 / 0;
        return "ok";

    }
}
